package com.glorysoft.sunnypda.model

import com.glorysoft.sunnypda.base.BaseRepository
import com.glorysoft.sunnypda.base.Constant
import com.glorysoft.sunnypda.entity.GetUsersEntity
import com.glorysoft.sunnypda.entity.LoginEntity
import com.glorysoft.sunnypda.entity.RepairInfoEntity
import com.glorysoft.sunnypda.entity.RepairListEntity
import com.google.gson.JsonObject
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse


/**
 * FileName: LoginRepository
 * Author: XJH
 * Date: 2021/5/24 17:11
 * Description:
 * History:
 */
class RepairRepository : BaseRepository() {

    suspend fun getRepairListFroUser(map: JsonObject): RepairListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_RFR_OP")
            .addAll(getInJsonData(map,"VIEW_PDA_RFR_OP"))
            .toResponse<RepairListEntity>()
            .await()

    }

    suspend fun getReminder(map: JsonObject): Any {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_LOG_BY_RFRID")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_LOG_BY_RFRID"))
            .toResponse<Any>()
            .await()

    }

    suspend fun getRepairListFroUser2(map: JsonObject): RepairListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_RPR_OP")
            .addAll(getInJsonData(map,"VIEW_PDA_RPR_OP"))
            .toResponse<RepairListEntity>()
            .await()

    }
    suspend fun getRepairListFroEqp(map: JsonObject): RepairInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_RFR_EQP")
            .addAll(getInJsonData(map,"VIEW_PDA_RFR_EQP"))
            .toResponse<RepairInfoEntity>()
            .await()

    }

    suspend fun reportFault(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_RFR_ADD")
            .addAll(getInJsonData(map,"TRAN_PDA_RFR_ADD"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getRepairInfo(map: JsonObject): RepairInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_RFRADD_INFO_BYRFRID")
            .addAll(getInJsonData(map,"VIEW_PDA_RFRADD_INFO_BYRFRID"))
            .toResponse<RepairInfoEntity>()
            .await()

    }
    suspend fun getUserInfo(map: JsonObject): ArrayList<GetUsersEntity> {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_GETUSERS")
            .addAll(getInJsonData(map,"VIEW_PDA_GETUSERS"))
            .toResponse<ArrayList<GetUsersEntity>>()
            .await()

    }
    suspend fun getTypeInfo(map: JsonObject): ArrayList<GetUsersEntity> {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_GET_RFR_TYPE")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_GET_RFR_TYPE"))
            .toResponse<ArrayList<GetUsersEntity>>()
            .await()

    }

    suspend fun changeRepairStatus(map: JsonObject): RepairInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_RFR_UPDATERFRSTATUS")
            .addAll(getInJsonData(map,"TRAN_PDA_RFR_UPDATERFRSTATUS"))
            .toResponse<RepairInfoEntity>()
            .await()

    }
}